package com.jinzhi;

import com.jinzhi.jzweb.domain.ExaminationResultsComDO;
import com.jinzhi.sys.domain.UserDO;

import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/*
 *  @author : JingChangTian
 *  @date   : 2023/5/24 10:48
 *  @description :
 *
 */
public class text1 {
    private static int i = 1;

    //默认B赛场第一题五名裁判分数集合
    private static List<Serializable>  scores = new ArrayList<>();

    //默认A赛场第一题五名裁判分数集合
    private static List<Serializable>  scoingb = new ArrayList<>();

    //默认C赛场第一题五名裁判分数集合
    private static List<Serializable>  scoingc = new ArrayList<>();

    public text1(){

        this.scores.add(0.1);
        this.scores.add(0.2);
        this.scores.add(0.3);
        this.scores.add(0.4);
        this.scores.add(0.5);

        this.scoingb.add(0.1);
        this.scoingb.add(0.2);
        this.scoingb.add(0.3);
        this.scoingb.add(0.4);
        this.scoingb.add(0.5);

        this.scoingc.add(0.1);
        this.scoingc.add(0.2);
        this.scoingc.add(0.3);
        this.scoingc.add(0.4);
        this.scoingc.add(0.5);
    }

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InstantiationException, InvocationTargetException, ClassNotFoundException {
        List<UserDO> userDOS  = new ArrayList<>();
        UserDO userDO1 = new UserDO();
        userDO1.setName("张三");
        userDOS.add(userDO1);
        UserDO userDO2 = new UserDO();
        userDO2.setName("李四");
        userDOS.add(userDO2);
        UserDO userDO3 = new UserDO();
        userDO3.setName("王五");
        userDOS.add(userDO3);
        UserDO userDO4 = new UserDO();
        userDO4.setName("赵六 ");
        userDOS.add(userDO4);



        List<UserDO> userDOS2  = new ArrayList<>();
        UserDO userDO1s = new UserDO();
        userDO1s.setName("田经昌");
        userDOS2.add(userDO1s);
        UserDO userDO2s = new UserDO();
        userDO2s.setName("李四");
        userDOS2.add(userDO2s);
        UserDO userDO3s = new UserDO();
        userDO3s.setName("王五");
        userDOS2.add(userDO3s);
        UserDO userDO4s = new UserDO();
        userDO4s.setName("赵六 ");
        userDOS2.add(userDO4s);


        List<UserDO> xx = userDOS.stream().filter(o1 -> !userDOS2.stream().anyMatch(o2 -> o1.getName().equals(o2.getName()))).collect(Collectors.toList());

        xx.forEach(a->{
            System.out.println(a.getName());
        });



        //A裁判打分标识
        String B = "score";
        //B裁判打分标识
        String A = "scoingb";
        //B裁判打分标识
        String C = "scoingc";
        //获取class对象
        Class classc = text1.class;
        ExaminationResultsComDO examinationResultsComDO = new ExaminationResultsComDO();
        //获得无参构造方法
        Constructor[] constructor = classc.getConstructors();
        //使用class对象实例化一个对象,实例化调用无参构造行数一次，初始话数据
        Object obj = classc.newInstance();
        //获取实例化对象方法
        Method method = classc.getMethod("ABC", ExaminationResultsComDO.class, String.class, List.class);
        //调用实例化对象方法
        method.invoke(obj,examinationResultsComDO,B,scores);
        method.invoke(obj,examinationResultsComDO,A,scoingb);
        method.invoke(obj,examinationResultsComDO,C,scoingc);
        a1();
        a2();

        Random random = new Random();
        for (int j = 0; j < 100; j++) {
            System.out.println(random.nextInt(900000)+100000);
        }


    }


    /**
     * 赛场打分
     * @param examinationResultsComDO
     * @throws NoSuchFieldException
     * @throws IllegalAccessException
     */
    public void ABC(ExaminationResultsComDO examinationResultsComDO,String ABC,List<Serializable> scores) throws NoSuchFieldException, IllegalAccessException {
        for (int i = 1; i <= scores.size(); i++) {
            Field f = examinationResultsComDO.getClass().getDeclaredField(ABC + i);
            //授权访问私有变量
            f.setAccessible(true);
            f.set(examinationResultsComDO, scores.get(i - 1));
            Double ss = (Double) f.get(examinationResultsComDO);
            System.out.println("第" + i + "个字段属性:" + f.getName() + "=" + ss);
        }
        System.out.println("");
    }

    public static int a1(){
        System.out.println(i+1);
        return i+1;
    }

    public static int a2(){
        System.out.println(i+2);
        return i+2;
    }

}
